﻿Shader "Custom/TestShader14"
{
	Properties
	{
		_NearTex("NearTex", 2D) = "white" {}
        _FarTex("FarTex", 2D) = "white" {}
        _NearSpeed("NearSpeed", float) = 8
        _FarSpeed("FarSpeed", float) = 8
	}
	SubShader
	{
		Tags { "RenderType"="Transparent" "Queue" = "Transparent" "Ignoreprojector" = "True" }

		Pass
		{
            Tags {"LightMode"= "ForwardBase"}
            
            ZWrite Off
            Blend SrcAlpha OneMinusSrcAlpha

			CGPROGRAM
			#pragma vertex vert
			#pragma fragment frag
			#pragma multi_compile_fwdbase
			
			#include "UnityCG.cginc"

            sampler2D _NearTex;
            float4 _NearTex_ST;
            sampler2D _FarTex;
            float4 _FarTex_ST;

            float _NearSpeed;
            float _FarSpeed;

			struct a2v
			{
				float4 vertex : POSITION;
				float2 uv : TEXCOORD0;
			};

			struct v2f
			{
				float4 uv : TEXCOORD0;
				float4 pos : SV_POSITION;
			};
			
			v2f vert (a2v v)
			{
				v2f o;
				o.pos = UnityObjectToClipPos(v.vertex);
                o.uv.xy = v.uv.xy * _NearTex_ST.xy + _NearTex_ST.zw;
                o.uv.zw = v.uv.xy * _FarTex_ST.xy + _FarTex_ST.zw;
                float nearOffset = _Time.y * _NearSpeed;
                float farOffset = _Time.y * _FarSpeed;

                o.uv.x += frac(nearOffset);
                o.uv.z += frac(farOffset);
				return o;
			}
			
			fixed4 frag (v2f i) : SV_Target
			{
                fixed4 nearColor = tex2D(_NearTex, i.uv.xy);
                fixed4 farColor = tex2D(_FarTex, i.uv.zw);

                fixed4 color = lerp(farColor, nearColor, nearColor.a);
				return color;
			}
			ENDCG
		}
	}
}
